<?php

class Contact extends public_controller
{
	
    function __construct()
    {
        parent::__construct();
		
		//$this->template->set_layout('contact');
		
    }

    public function index()
    {
		
        $sql = $this->db->get('contact')-> row_array();
		$this->template->title('Liên hệ')
               //->set_metadata('keywords', $meta['meta_keyword'])
               //->set_metadata('description',$meta['meta_desc'])
               //->set('newsTop', $articleTop)
               ->set('title', 'Liên hệ')
               ->set('info', $sql)
               ->build('contact');
    }
	
    function sendContact()
    {

        $data['content'] = $this->input->get('message');
        $data['email'] = $this->input->get('email');
        $data['name'] = $this->input->get('name');
        $data['phone'] = $this->input->get('phone');

        $this->loadMail();
        $this->email->from($data['email'], $data['name']);
        $this->email->to('tinapc@gmail.com, supper_itpro@yahoo.com');
        $this->email->subject('CONTACT FROM Xtaseaanalytic.com');
        $this->email->message($this->load->view('temp_contact', $data,TRUE));
        $this->email->set_newline("\r\n");	

        if($this->email->send()) {

                $_data = array('status' => true ,'message' => 'Your request has been sent to us');
        } else {
                $_data = array('status' => false, 'message' => 'Send mail faild'); 
        }

        echo json_encode($_data);
    }

}